const
    regex_FIR_TOP_header             = /\/\*\*\${FIR_TOP_header}\*\//ig,
    regex_FIR_TOP_disclaimer         = /\/\*\*\${FIR_TOP_disclaimer}\*\//ig,
    //
    regex_FIR_TOP_package            = /\/\*\*\${FIR_TOP_package}\*\//g,
    regex_FIR_TOP_import_1           = /\/\*\*\${FIR_TOP_import_1}\*\//g,
    regex_FIR_TOP_import_2           = /\/\*\*\${FIR_TOP_import_2}\*\//g,
    //
    regex_FIR_URI_fnoi               = /\/\*\*\${FIR_URI_fnoi}\*\//g,
    regex_FIR_AT_context             = /\/\*\*\${FIR_AT_context}\*\//g,
    //
    regex_FIR_FN_id                  = /\/\*\*\${FIR_FN_id}\*\//ig,
    regex_FIR_FN_version             = /\/\*\*\${FIR_FN_version}\*\//ig,
    regex_FIR_criteria               = /\/\*\*\${FIR_criteria}\*\//ig,
    regex_FIR_FN_name                = /\/\*\*\${FIR_FN_name}\*\//ig,
    regex_FIR_function_documentation = /\/\*\*\${FIR_function_documentation}\*\//ig,
    regex_FIR_FN_args                = /\/\*\*\${FIR_FN_args}\*\//ig,
    regex_FIR_FN_body                = /\/\*\*\${FIR_FN_body}\*\//ig
;

let
    render_fn = async function ({
                                   'template': template = "",
                                   //
                                   'FIR_TOP_header':     FIR_TOP_header = "",
                                   'FIR_TOP_disclaimer': FIR_TOP_disclaimer = "",
                                   //
                                   'FIR_TOP_package':  FIR_TOP_package = "",
                                   'FIR_TOP_import_1': FIR_TOP_import_1 = "",
                                   'FIR_TOP_import_2': FIR_TOP_import_2 = "",
                                   //
                                   'FIR_URI_fnoi':   FIR_URI_fnoi = "",
                                   'FIR_AT_context': FIR_AT_context = "[]",
                                   //
                                   'FIR_FN_id':                  FIR_FN_id = "",
                                   'FIR_FN_version':             FIR_FN_version = "",
                                   'FIR_criteria':               FIR_criteria = "",
                                   'FIR_function_documentation': FIR_function_documentation = "",
                                   'FIR_FN_name':                FIR_FN_name = "",
                                   'FIR_FN_args':                FIR_FN_args = "",
                                   'FIR_FN_body':                FIR_FN_body = ""
                               }) {

        try {
            template = template.replace(regex_FIR_TOP_header, FIR_TOP_header);
            template = template.replace(regex_FIR_TOP_disclaimer, FIR_TOP_disclaimer);
            //
            template = template.replace(regex_FIR_TOP_package, FIR_TOP_package);
            template = template.replace(regex_FIR_TOP_import_1, FIR_TOP_import_1);
            template = template.replace(regex_FIR_TOP_import_2, FIR_TOP_import_2);
            //
            template = template.replace(regex_FIR_URI_fnoi, FIR_URI_fnoi);
            template = template.replace(regex_FIR_AT_context, FIR_AT_context);
            //
            template = template.replace(regex_FIR_FN_id, FIR_FN_id);
            template = template.replace(regex_FIR_FN_version, FIR_FN_version);
            template = template.replace(regex_FIR_criteria, FIR_criteria);
            template = template.replace(regex_FIR_function_documentation, FIR_function_documentation);
            template = template.replace(regex_FIR_FN_name, FIR_FN_name);
            template = template.replace(regex_FIR_FN_args, FIR_FN_args);
            template = template.replace(regex_FIR_FN_body, FIR_FN_body);
            //console.log(template);
            //debugger;
            return template;

        } catch (err) {
            throw err;
        } // try
    }
;

exports.render_fn = render_fn;